/**
 * Copyright (c) Enalean, 2018. All Rights Reserved.
 *
 * This file is a part of Tuleap.
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */

@import '../../card-fields';
@import 'backlog-item-moves';

.backlog-item-details {
    display: flex;
    position: relative;
    flex-direction: column;
    width: 100%;
    transition: border-color 75ms ease-in-out, background-color 75ms ease-in-out;
    border: 1px solid $tlp-ui-border-normal;
    border-radius: 3px;
    background: $tlp-ui-white;
    cursor: move;

    @for $i from 1 through length($tlp-swatch-color-names) {
        &.#{nth($tlp-swatch-color-names, $i)} {
            > .backlog-item-details-type-border {
                border-left-color: nth($tlp-swatch-color-primaries, $i);
            }
        }
    }

    &.closed {
        border-color: transparentize($tlp-ui-border-normal, .5);
        background: transparent;

        .backlog-item-details-id {
            color: transparentize($tlp-ui-dimmed, .4);
        }

        .backlog-item-details-type-border,
        .backlog-item-details-title,
        .backlog-item-details-parent,
        .backlog-item-details-effort-container,
        .extra-card-fields {
            opacity: .5;
        }
    }

    @keyframes blink {
        0% {
            border-color: $tlp-ui-border-normal;
            background: $tlp-ui-white;
        }

        50% {
            border-color: $tlp-ui-info;
            background: transparentize($tlp-ui-info, .9);
        }

        100% {
            border-color: $tlp-ui-border-normal;
            background: $tlp-ui-white;
        }
    }

    &.updating {
        transition: border-color 75ms ease-in-out, background-color 75ms ease-in-out;
        animation: blink 1200ms ease-in-out alternate infinite;
    }

    &.updated {
        transition: border-color 75ms ease-in-out, background-color 75ms ease-in-out;
        animation: pulse 500ms ease-in-out;
        border-color: $tlp-ui-success;
        background: transparentize($tlp-ui-success, .9);
    }

    &.created {
        transition: border-color 75ms ease-in-out, background-color 75ms ease-in-out;
        animation: pulse 500ms ease-in-out;
        border-color: $tlp-ui-success;
        background: transparentize($tlp-ui-success, .9);
    }

    &:hover,
    &.moving-to {
        > .backlog-item-details-moves {
            transition: opacity 100ms ease-in-out 500ms;
            opacity: 1;
        }

        > .backlog-item-details-content {
            > .backlog-item-details-parent,
            > .backlog-item-details-effort-container {
                left: -15px;
            }
        }
    }
}

.backlog-item-details-type-border {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-left-width: 4px;
    border-left-style: solid;
    border-top-left-radius: 2px;
    border-bottom-left-radius: 2px;
}

.backlog-item-details-content {
    display: flex;
    position: relative;
    flex: 1 0 auto;
    align-items: baseline;
    width: 100%;
    padding: 5px 5px 5px $tlp-half-spacing;
}

.backlog-item-details-id {
    display: flex;
    flex: 0 0 auto;
    margin: 0 7px 0 0;
    color: $tlp-ui-dimmed;
    font-size: 12px;
    white-space: nowrap;

    &:hover {
        opacity: .7;
        text-decoration: none;
    }
}

.backlog-item-details-id-icon {
    visibility: hidden;
    margin: 0 0 0 4px;
}

.tlp-dropdown > .backlog-item-details-id > .backlog-item-details-id-icon {
    visibility: visible;
}

.backlog-item-details-title {
    flex: 1 1 auto;
    font-size: 14px;
    line-height: 24px;
}

.backlog-item-details-parent {
    position: relative;
    left: 0;
    flex: 0 1 auto;
    align-self: center;
    margin: 0 5px;
    transition: left 100ms ease-in-out 500ms;
    color: $tlp-theme-color;
    font-size: 12px;
    text-align: right;
}

.backlog-item-details-effort-container {
    position: relative;
    left: 0;
    flex: 0 0 auto;
    align-self: center;
    min-width: 40px;
    transition: left 100ms ease-in-out 500ms;
    text-align: right;
}
